package com.example.springbootdesign.controller;

import com.alibaba.fastjson.JSON;
import com.example.springbootdesign.config.ReadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PropController {

    @Value("${my.name:默认值}")
    private String name;

    @Value("#{'test value'}")
    private String value;

    @Value("#{systemProperties['os.name']}")
    private String systemPropertiesName;

    @Autowired
    private ReadProperties readProperties;

    @RequestMapping("getProp")
    public String getProp(){
        System.out.println(name);
        System.out.println(systemPropertiesName);
        String s = JSON.toJSONString(readProperties);
        System.out.println(s);
        return value;
    }

}
